package zjc.案例练习;

import java.util.Random;
import java.util.Scanner;

public class 开发验证码 {
    public static void main(String[] args) {
        int n;
        Scanner sr=new Scanner(System.in);
        System.out.println("输入验证码长度:");
        n=sr.nextInt();
        System.out.println("验证码为");
        System.out.println(p(n));
    }
    public static String p(int n){
        Random sj=new Random();
        String yzm="";
        for (int i = 0; i < n; i++) {
            int leixing=sj.nextInt(3);
            switch (leixing){
                case 0:char t1= (char)(sj.nextInt(26)+65);yzm +=t1;break;//大写
                case 1:char t2= (char)(sj.nextInt(26)+97);yzm +=t2;break;//小写
                case 2:yzm +=sj.nextInt(10);break;//数字
            }

        }
        return yzm;
    }
}
